/**
 * Captain
 * © 2017 Captain copyright，All rights reserved.
 * http://www.sccaptain.com.cn
 * 
 * JAVA : 8
 * 文  件  名: CompoundExpression.java
 * 创  建  人: liutao (liu.tao@sccaptain.com.cn)
 * 创建时间: 2017年8月2日 下午2:37:28
 * 版         本: 1.0.0
 * 备         注:
 * 修订历史:
 */
package com.material.c2c.core.criteria;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 
 * 
 * @since 1.0
 * @version 1.0
 * @author liutao (liu.tao@sccaptain.com.cn)
 */
public class CompoundExpression extends CriterionExpression{
  
  private BooleanOperator booleanOperator;
  private List<CriterionExpression> expressions = new ArrayList<CriterionExpression>();
  
  public CompoundExpression(BooleanOperator booleanOperator){
    this.booleanOperator = booleanOperator;
  }
  public CompoundExpression(
      BooleanOperator booleanOperator,CriterionExpression ...expressions){
    this.booleanOperator = booleanOperator;
    this.applyExpressions(expressions);
  }
  
  private void applyExpressions(CriterionExpression ... expressions) {
    applyExpressions( Arrays.asList( expressions ) );
  }

  private void applyExpressions(List<CriterionExpression> expressions) {
    this.expressions.clear();
    this.expressions.addAll(expressions);
  }
  
  public List<CriterionExpression> getExpressions() {
    return expressions;
  }
  public void setExpressions(List<CriterionExpression> expressions) {
    this.expressions = expressions;
  }
  public BooleanOperator getBooleanOperator() {
    return booleanOperator;
  }
  public void setBooleanOperator(BooleanOperator booleanOperator) {
    this.booleanOperator = booleanOperator;
  }
}
